package com.dc.refactoring._5_简化函数调用._4_SeparateQueryFromModifier;

import java.util.List;
import java.util.Objects;

public class OldDemo {


    void checkSecurity(List<String> peoples){
        String found = foundMiscreant(peoples);
        someLaterCode(found);

    }

    /**
     * 入侵系统
     * 发现有人入侵，会告诉入侵者的名称，并发送一个警报
     * @param peoples
     * @return
     */
    String foundMiscreant(List<String> peoples) {
        for (String people: peoples) {
            if (Objects.equals(people, "Don")) {
                sendAlert();
                return "Don";
            } else if (Objects.equals(people, "John")) {
                sendAlert();
                return "John";
            }
        }
        return "";
    }

    private void sendAlert() {
         System.out.println("SEND");
    }

    private void someLaterCode(String found) {
    }

}
